package com.message.queue.rocket.consumer;

import com.message.queue.constant.RocketConstant;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;

/**
 * Created by 张波 on 2019/10/14.
 */
public class PushConsumer2 extends ConsumerParent {

    public static void main(String[] args) throws MQClientException {
        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(CONSUMER_GROUP);
        consumer.setNamesrvAddr(RocketConstant.NAME_SERVER);
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
        /*集群模型，默认*/
//        consumer.setMessageModel(MessageModel.CLUSTERING);
        /*广播模型*/
        consumer.setMessageModel(MessageModel.BROADCASTING);
        consumer.subscribe(ConsumerParent.TOPIC, "TagA");
        consumer.registerMessageListener(getListener());
        consumer.start();
    }

}
